package crmdna.mail;

import java.util.HashMap;
import java.util.Map;

import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;

@Entity
@Cache
public class MailStatsEntity {
  @Id
  String tag;

  int numSendAttempted;
  int numSent;
  int numRejects;
  int numSoftBounces;
  int numHardBounces;

  int numOpens;
  int numMobileOpens;

  int numOpensWithin1Hour;
  int numOpensWithin3Hours;
  int numOpensWithin24Hours;
  int numOpensWithin72Hours;
  int numOpensAfter72Hours;

  Map<String, Integer> countryVsNumOpens = new HashMap<>();
  Map<String, Integer> cityVsNumOpens = new HashMap<>();

  int numClicks;
  Map<String, Integer> urlVsNumClicks = new HashMap<>();

  int numSpams;

  public MailStatsProp toProp() {
    MailStatsProp mailStatsProp = new MailStatsProp();

    mailStatsProp.tag = tag;
    mailStatsProp.numSendAttempted = numSendAttempted;
    mailStatsProp.numSent = numSent;
    mailStatsProp.numRejects = numRejects;
    mailStatsProp.numSoftBounces = numSoftBounces;
    mailStatsProp.numHardBounces = numHardBounces;
    mailStatsProp.numOpens = numOpens;
    mailStatsProp.numMobileOpens = numMobileOpens;

    mailStatsProp.numOpensWithin1Hour = numOpensWithin1Hour;
    mailStatsProp.numOpensWithin3Hours = numOpensWithin3Hours;
    mailStatsProp.numOpensWithin24Hours = numOpensWithin24Hours;
    mailStatsProp.numOpensWithin72Hours = numOpensWithin72Hours;
    mailStatsProp.numOpensAfter72Hours = numOpensAfter72Hours;

    mailStatsProp.countryVsNumOpens = countryVsNumOpens;
    mailStatsProp.cityVsNumOpens = cityVsNumOpens;
    mailStatsProp.numClicks = numClicks;
    mailStatsProp.urlVsNumClicks = urlVsNumClicks;

    mailStatsProp.numSpams = numSpams;

    return mailStatsProp;
  }
}
